package com.offcn.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: wy
 * @Date: 2022/9/23 18:44
 * <p>
 * 路由模式（Direct）
 */
@Configuration
public class QueueConfig04 {

    private String direct01 = "direct01";

    private String direct02 = "direct02";

    //交换机类型 三种 type =   fanout 广播 direct 定向 topic 通配符

    private final String directExchange = "directExchange";


    //@Bean
    public Queue queue1() {
        return new Queue(direct01);
    }

    //@Bean
    public Queue queue2() {
        return new Queue(direct02);
    }

    //@Bean
    public DirectExchange exchange() {
        return new DirectExchange(directExchange);
    }


    //@Bean
    public Binding bind1(Queue queue1, DirectExchange exchange) {
        return BindingBuilder.bind(queue1).to(exchange).with("delete");
    }

   // @Bean
    public Binding bind2(Queue queue2, DirectExchange exchange) {
        return BindingBuilder.bind(queue2).to(exchange).with("add");
    }
}
